<?php

class model_module_breadcrumbs extends database_mysql {
    
    public function mdbr_get_name_seokey($seokey) {
        $tb = prefix . 'categories_lang';
        $str = "SELECT
                    cat.CatName
                FROM
                     $tb AS cat
                WHERE
                    cat.SeoKey = '$seokey'";
        $row = parent::mysql_fetch_one_rows($str);
        parent::mysql_close_connection();

        return $row;
    }
	
	public function mdbr_get_seokey($seokey) 
	{
		$rowx = array();
		if(!empty($seokey)){
		
			if(is_int($seokey))
			{
				$str_where = " ".prefix."categories.ID = '".$seokey."' AND ";
			}
			else{
				$str_where = " ".prefix."categories_lang.SeoKey = '".$seokey."' AND ";
			}
			$str = "SELECT
						".prefix."categories.ID,
						".prefix."categories.PID,
						".prefix."categories_lang.SeoKey,
						".prefix."categories_lang.CatName
					FROM
						".prefix."categories_lang
						INNER JOIN ".prefix."categories 
						ON ".prefix."categories_lang.CatID = ".prefix."categories.ID				
					WHERE
						".$str_where."
						".prefix."categories.Define = 'sub' AND
						".prefix."categories.App='public'
			";
			$row = parent::mysql_fetch_one_rows($str);
			$rowx[] = $row;
			if($row['PID'])
			{	
				$rowsx = $this->mdbr_get_seokey(intval($row['PID']));
				foreach($rowsx as $r)
				$rowx[] = $r;
			}
		}
        return $rowx;
    }

}